package config

import (
	"github.com/pkg/errors"
	"gopkg.in/yaml.v3"
	"io/ioutil"
)

type config struct {
	Host  []string `yaml:"host"`
	Topic string   `yaml:"topic"`
}

func GetConfig() (conf config, err error) {
	yamlFile, err := ioutil.ReadFile("./config/config.config.yml")
	if err != nil {
		return conf, errors.Wrap(err, "ERR: fail to get config")
	}
	err = yaml.Unmarshal(yamlFile, &conf)
	if err != nil {
		return conf, errors.Wrap(err, "ERR: fail to get config")
	}
	return conf, nil
}
